//
//  MCThirdPartyShowInfoModel.m
//  LDYL
//
//  Created by MC on 2018/6/13.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCThirdPartyShowInfoModel.h"
#import "NSDictionary+helper.h"
#import "NSString+Helper.h"
#import "MCMineInfoModel.h"

@interface MCThirdPartyShowInfoModel ()<ApiManagerCallBackProtocol,ApiManagerProvider,ApiManagerProtocol>
{
    
    NSDictionary * _dic;
}
@end

@implementation MCThirdPartyShowInfoModel
singleton_m(MCThirdPartyShowInfoModel)
- (instancetype)initWithDic:(NSDictionary *)dic{
    
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}



- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
};
-(BOOL)isShowHud{
    return YES;
}
- (BOOL)isShowError{
    return NO;
}
- (BOOL)isShowNoNet{
    return NO;
}
- (BOOL)isShowNodata{
    return NO;
}
- (enum ManagerRequestMethod)requestMethod{
    
    return ManagerRequestMethodRequestMethodRestPOST;
}

- (enum APIResponseDataType)responseDataType{
    
    return APIResponseDataTypeJson;
}
- (void)refreashDataAndShow{
    
    ApiBaseManager *baseManager = [[ApiBaseManager alloc] initWithUrlProvider:self];
    baseManager.apiCallBackDelegate = self;
    baseManager.requestCustomizeDelegate = self;
    [baseManager loadData];
    
}

- (NSDictionary<NSString *,NSString *> *)headerForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *Token=@"";
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"token"]) {
        Token=[[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
    }
    
    return @{@"token":Token,@"platformCode":@"5"};
}

- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"web-api/api/v4/third_party_show_info";
    
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *timeString = [NSString getCurrentTimestamp];
    
    
    NSDictionary *dic =@{
                         };
    
    NSString *jsonStr = [dic convertToJsonData];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",jsonStr,[[NSUserDefaults standardUserDefaults] objectForKey:@"token"],timeString];
    return @{@"params":jsonStr,
             @"sign":[sign MD5],
             @"timestamp":timeString
             };
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
    
    
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager.ResponseRawData);
    }
    
}

- (void)managerCallAPIDidFailedWithManager:(ApiBaseManager *)manager errorCode:(NSString *)errorCode{
    
    if (self.callBackFailedBlock) {
        self.callBackFailedBlock(manager,errorCode);
    }
    NSLog(@"third_party_show_info-er=----%@",errorCode);
}

-(void)setDataWithDic:(NSArray *)arr{
    
    _zhuanzhang_dataArray = [[NSMutableArray alloc]init];
    _baobiao_dataArray = [[NSMutableArray alloc]init];
    _isZhuanZhangShow = NO;
    _isBaoBiaoShow = NO;
    for (NSDictionary * dic in arr) {
        
        MCShowInfoModel * model = [[MCShowInfoModel alloc]init];
        //        model.ID=[NSString stringWithFormat:@"%@",dic[@"ID"]];
        model.ThirdpartyValue=[NSString stringWithFormat:@"%@",dic[@"ThirdpartyValue"]];
        model.ThirdpartyText=[NSString stringWithFormat:@"%@",dic[@"ThirdpartyText"]];
        model.IsShow=[NSString stringWithFormat:@"%@",dic[@"IsShow"]];
        model.LotteryToThirdParty=[NSString stringWithFormat:@"%@",dic[@"LotteryToThirdParty"]];
        model.ThirdPartyToLottery=[NSString stringWithFormat:@"%@",dic[@"ThirdPartyToLottery"]];
        
        
        //        if (![model.ThirdpartyValue isEqualToString:@"4"]) {
        [_baobiao_dataArray addObject:model];
        //        }
        
        [_zhuanzhang_dataArray addObject:model];
        
    }
    
    if (_zhuanzhang_dataArray.count>0) {
        _isZhuanZhangShow = YES;
    }
    if (_baobiao_dataArray.count>0) {
        _isBaoBiaoShow = YES;
    }
    
}

@end


@implementation MCShowInfoModel

@end

















